home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / SprocketInvaders / Source / CommonStuff.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  2.5 KB  |  79 lines  |  [TEXT/CWIE]

  1. //•    ------------------------------------------------------------------------------------------    •
  2. //•
  3. //•    Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  4. //•
  5. //•
  6. //•        You may incorporate this sample code into your applications without
  7. //•        restriction, though the sample code has been provided "AS IS" and the
  8. //•        responsibility for its operation is 100% yours.  However, what you are
  9. //•        not permitted to do is to redistribute the source as "DSC Sample Code"
  10. //•        after having made changes. If you're going to re-distribute the source,
  11. //•        we require that you make it clear in the source that the code was
  12. //•        descended from Apple Sample Code, but that you've made changes.
  13. //•
  14. //•    ------------------------------------------------------------------------------------------    •
  15.  
  16. // Common Stuff.h is a simple include file that holds a number of standard functions,
  17. // constants, and debugging macros.  Anything that isn't likely to change from program
  18. // to program.
  19.  
  20. #ifndef _COMMONSTUFF_
  21. #define _COMMONSTUFF_
  22.  
  23. #pragma once
  24.  
  25. /*********************************************************************************
  26.     DEBUGGING and ERROR HANDLING MACROS
  27.     
  28.     These macros should be used to create code with proper error handling.  In
  29.     the debugging version of the macros, they dump a string to the debugger before
  30.     dropping into the error handler.
  31.     
  32.     To turn debugging off, set the macro qDebugging to 0 before including Common Stuff.
  33.     
  34.     If an application wants to include special debugging code, the proper way to do this
  35.     is with something like:
  36.     
  37.     #if qDebugging
  38.           // do additional sanity checking here.
  39.     #endif
  40.     
  41.     Note that this should only be additional sanity checking code and not eliminate all error
  42.     checking code.
  43.     
  44. *********************************************************************************/
  45. #define qDebugging 0
  46. #ifndef qDebugging
  47.     #define qDebugging 0
  48. #endif
  49.  
  50. void DebugPrint(char *message, long error);
  51. void dprintf(char *format, ...);
  52.  
  53. #if qDebugging
  54.     #define SIGNAL_ERROR(msg, y)        {DebugPrint(msg, y); goto error;}
  55. #else
  56.     #define SIGNAL_ERROR(msg, y)        {goto error;}
  57. #endif
  58.  
  59. #define FAIL_NIL(y,msg)            if (y == NULL) SIGNAL_ERROR(msg, y)
  60. #define FAIL_OSERR(y,msg)        if (y != noErr) SIGNAL_ERROR(msg, y)
  61. #define FAIL_OSSTATUS(y,msg)    if (y != (OSStatus) 0) SIGNAL_ERROR(msg, y)
  62. #define FAIL_FALSE(y,msg)        if (!y) SIGNAL_ERROR(msg, y)
  63.  
  64. extern short gMySeed;
  65. extern UInt32 gMyRandomCount;    
  66. extern UInt32 gGameLoopIterations;
  67.  
  68. int Game_Random(int x);
  69.  
  70. StringPtr
  71. CopyPStr(
  72.     ConstStr255Param    inSourceStr,
  73.     StringPtr            outDestStr);
  74.  
  75. #endif /* _COMMONSTUFF_ */
  76.  
  77.     
  78.  
  79.